package com.work.mvc.view.panels.reports;

import com.vaadin.ui.*;
import com.work.constants.view.ComponentsSources;
import com.work.mvc.controler.ReportsController;
import com.work.reports.ReportType;

@SuppressWarnings("serial")
public abstract class ReportPanel extends AbsoluteLayout {
	
	protected ReportsController controller = new ReportsController(this);
	
	private Panel reportContent = new Panel();
	private Button generateButton = new Button();

	public ReportPanel(String title) {
		generateButton.setIcon(ComponentsSources.ICON_REPORT);
		generateButton.setStyleName("generate_button");
		generateButton.setData(getReportType());
		generateButton.addClickListener(controller);
		
		Component content = createContent();
		reportContent.setContent(content);
		reportContent.setSizeFull();
		reportContent.setCaption(title);
		reportContent.setStyleName("reportpanel");
		
		this.addComponent(reportContent);
		this.addComponent(generateButton, "top: 5px; right: 5px;");
		this.setSizeFull();
		this.setStyleName("roundedborder");
	}
	
	protected abstract ReportType getReportType();

	protected abstract Component createContent();
	
	protected abstract boolean isValid();
}
